#ifndef _CHUNK_H_
#define _CHUNK_H_

typedef unsigned char UBYTE;

enum BLOCK_TYPE : UBYTE { AIR, STONE, GRASS, DIRT, COBBLESTONE, WOOD, SAPLING, BEDROCK, WATER, STATIONARY_WATER,
						LAVA, STATIONARY_LAVA, SAND, GRAVEL, GOLD_ORE, IRON_ORE, COAL_ORE, LOG, LEAVES, SPONGE, GLASS,
						YELLOW_FLOWER = 37, RED_ROSE, BROWN_MUSHROOM, RED_MUSHROOM, GOLD_BLOCK, IRON_BLOCK, DOUBLE_STEP,
						STEP, BRICK, TNT, BOOKSHELF, MOSSY_COBBLESTONE, OBSIDIAN, TORCH, FIRE, MOB_SPAWNER, WOODEN_STAIRS,
						CHEST, REDSTONE_WIRE, DIAMOND_ORE, DIAMOND_BLOCK, WORKBENCH, CROPS, SOIL, FURNACE, BURNING_FURNACE,
						SIGN_POST, WOODEN_DOOR, LADDER, MINECART_TRACKS, COBBLESTONE_STAIRS, WALL_SIGN, LEVER, STONE_PRESSURE_PLATE,
						IRON_DOOR, WOODEN_PRESSURE_PLATE, REDSTONE_ORE, GLOWING_REDSTONE_ORE, REDSTONE_TORCH_OFF, REDSTONE_TORCH_ON,
						STONE_BUTTON, SNOW, ICE, SNOW_BLOCK, CACTUS, CLAY, REED, JUKEBOX, FENCE, PUMPKIN, NETHERSTONE, SLOW_SAND,
						LIGHTSTONE, PORTAL, JACK_O_LANTERN, MAX_TYPE, BAD_X_PARAM = 253, BAD_Y_PARAM = 254, BAD_Z_PARAM = 255};

class Chunk
{
private:
	int xPos;
	int zPos;
	UBYTE BlockId[32768];
	UBYTE AdditionalData[16384];
	UBYTE SkyLight[16384];
	UBYTE BlockLight[16384];
	UBYTE HeightMap[256];

public:
	//constructor sets all the crap to zero
	Chunk();
	void Zero();

	//simple accessors and mutators
	int getXPos() { return xPos; }
	int getZPos() { return zPos; }
	void setXPos( int x ) { xPos = x; }
	void setZPos( int z ) { zPos = z; }

	void fillBlockId(UBYTE* blockStream);
	void fillAdditionalData(UBYTE* dataStream);
	void fillSkylightData(UBYTE* skyStream);
	void fillBlocklightData(UBYTE* blocklightStream);
	void fillHeightMap(UBYTE* heightStream);

	UBYTE const* GetBlockIds() const		{ return BlockId; }
	UBYTE const* GetBlockData() const		{ return AdditionalData; }
	UBYTE const* GetBlockSkyLight() const	{ return SkyLight; }
	UBYTE const* GetBlockLight() const		{ return BlockLight; }
	UBYTE *GetBlockLight()					{ return BlockLight; }
	UBYTE const* GetBlockHeightMap() const	{ return HeightMap; }	

	//complex accessors and mutators
	BLOCK_TYPE getBlockType(int x, int y, int z);
	
	//loading from an nbt.
	void LoadFromNBT(const char *_szFileName);
};


#endif